package com.sky.demo.aes;

import java.security.MessageDigest;

public class Md5 {

    public static String getSignatureString(String clientId, String appKey, String timeStamp, String jsonBodyStr, String appSecret) {
        String waitSignatureString = clientId + ":" + appKey + ":" + jsonBodyStr + ":" + timeStamp + ":" + appSecret;
        return encodingMD5(waitSignatureString, "UTF-8");
    }

    public static final String encodingMD5(String srcStr, String charset) {
        try {
            byte[] btInput = srcStr.getBytes(charset);
            MessageDigest mdInst = MessageDigest.getInstance("MD5");
            mdInst.update(btInput);
            byte[] md = mdInst.digest();
            StringBuffer sb = new StringBuffer();

            for(int i = 0; i < md.length; ++i) {
                int val = md[i] & 255;
                if (val < 16) {
                    sb.append("0");
                }

                sb.append(Integer.toHexString(val));
            }

            return sb.toString();
        } catch (Exception var8) {
            var8.printStackTrace();
            return null;
        }
    }

    public static void main(String[] args) {
        String clientId = "AC2022090000000001";
        String appKey = "R4H8AKmBuXgGk2Jz1l6cTkUTh7ICI8WfxUKTfsdNtWs";
        String timeStamp = String.valueOf(System.currentTimeMillis());
        System.out.println(timeStamp);
        String jsonBodyStr = "{\"appKey\":\"R4H8AKmBuXgGk2Jz1l6cTkUTh7ICI8WfxUKTfsdNtWs\"}";
        String appSecret = "q67Hv0lxbVZLsGFhluYiYJmeQ7ZR7vJ1GyjAgD6GtmuSgNw1zSKOKvSeKqb24dVEqw7y86TqrCTNF7xzJQ";
        String signatureString = getSignatureString(clientId, appKey, timeStamp, jsonBodyStr, appSecret);

        System.out.println(signatureString);



    }
}
